//
//  SSEmoticonKeyboardView.swift
//  SSSina
//
//  Created by ss on 2017/7/10.
//  Copyright © 2017年 ss. All rights reserved.
//

import UIKit

class SSEmoticonKeyboardView: UIView {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //MARK: - 设置视图
    private func setupUI(){
        // 设置大小
        self.frame.size = CGSize(width: SSSCREENW, height: 216)
        backgroundColor = UIColor(patternImage: UIImage(named:"emoticon_keyboard_background")!)
        
        // 添加控件
        addSubview(bottomView)
        addSubview(pageView)
        // 添加约束
        bottomView.snp.makeConstraints { (make) in
            make.height.equalTo(35)
            make.left.bottom.right.equalTo(self)
        }
        
        pageView.snp.makeConstraints { (make) in
            make.left.top.right.equalTo(self)
            make.bottom.equalTo(bottomView.snp.top)
        }
        
        
        // 监听底部视图的按钮点击
        bottomView.closure = {(type) in
            switch type {
            case .recent:
                print("最近")
            case .normal:
                print("默认")
            case .emoji:
                print("emoji")
            case .lxh:
                print("浪小花")
            }
            
        }
        
    }
    
    //MARK: - 懒加载控件
    private lazy var bottomView: SSEmoticonBottomView = SSEmoticonBottomView()
    // 自定义表情键盘配图
    private lazy var pageView: SSEmoticonPageView = {
        let view = SSEmoticonPageView()
        // 分页
        view.isPagingEnabled = true
        // 弹簧效果
        view.bounces = false
        // 隐藏滚动条
        view.showsVerticalScrollIndicator = false
        view.showsHorizontalScrollIndicator = false
        return view
    }()
    
}
